<%@page import="java.util.ArrayList"%>
<%@page import="dto.messageDTO"%>
<%@page import="vo.messageVO"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src = '../js/message.js'></script>
<link rel="stylesheet" href="../css/message.css">

</head>
<body>
<jsp:useBean id="vo" class="vo.messageVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>
<%
	// 받은 번호에따라 알아서 셋팅됨
	// 1 : 받은 쪽지 , 2: 보낸 쪽지
	
		request.setCharacterEncoding("utf-8");			// 한글이 깨지지 않도록. 
		int msg_type = 1;
		try{
			msg_type = Integer.parseInt(request.getParameter("msg_type"));
		}catch(Exception e){
			msg_type = 1;
		}
		
		String m_id = (String)session.getAttribute("sessionMid");
		
		String message_view = request.getParameter("message_view");	
		if(message_view==null){
			message_view = "message_view.jsp";	
		}
		
		messageVO mvo = vo;
		mvo.setM_id(m_id);
		mvo.setChoose_number(msg_type);	// 받은 쪽지
		
		System.out.print("메시지 리스트에서 찍은 m_id : " + mvo.getM_id());
		messageDTO mdto = new messageDTO(mvo);
		mdto.list_size_set(5);
		ArrayList<messageVO> al = mdto.list();
		System.out.print("------------------------------------------------------" + al.size());
		
%>

	<form name = 'hiddenFrm' method='post'>
	 	<input type='hidden' name="nowPage"/>
	 	<input type='hidden' name='choose_number'/>
	 	<input type='hidden' name='msg_number'/>
	 	<input type='hidden' name='f_user_name'/>
	 	<input type='hidden' name='t_user_name'/>
	 	<input type='hidden' name='m_id' value="<%=mvo.getM_id()%>"/>
	</form>
	
<div>
	<table id="message_mini_table">
		<tr id="message_mini_title_items">
			<td id="message_mini_title_contents" class="message_title">내&nbsp;&nbsp;&nbsp;용</td>
			<td id="message_mini_title_send_date" class="message_title">보낸사람</td>
		</tr>
		<%
			for(int i=0; i<al.size(); i++){ 
		%>
		<tr id="message_mini_list_items">
			<td id="message_mini_list_contents">
				<a href = '#' onclick='goView(<%=mdto.getNowPage()%>,<%=al.get(i).getMsg_number()%>,
			"<%=al.get(i).getT_user_name()%>","<%=al.get(i).getF_user_name()%>", <%=msg_type%>)'>
			<%=al.get(i).getMsg_title() %></a>
			<% if(al.get(i).getMsg_confirm() == 0){ %> <div id='board_list_b_title3'><img alt="" src="../images/icon_new.gif"> </div> 
			<%}%>
			</td>
			<td id="message_mini_send_date">
				<%=al.get(i).getF_user_name() %>
			</td>
		</tr>
		<%} %>
	</table>
</div>



</body>
</html>